var jwim = {
	Utils : {},
	Callbacks : {},
	Scope : function(thisw) {
		this.thisw = thisw;
		this._eval = function(s) {
			eval(s)
		}
	}
};
jwim.Manager = function(c) {
	this.windows = [];
	this.nextid = 1;
	this.selectedWindow = null;
	this.mouse = {
		cur : {
			x : 0,
			y : 0
		},
		click : {
			x : 0,
			y : 0
		}
	};
	this.draggingWin = null;
	this.moveCallback = jwim.Callbacks.move(this);
	this.resizeCallback = jwim.Callbacks.resize(this);
	this.dragStop = jwim.Callbacks.dragStop(this);
	this.opts = {
		classWindow : "JMWindow",
		classActiveWindow : "activeJMWindow",
		classContent : "content",
		classTitle : "title",
		classIcon : "JMIcon",
		classActiveIcon : "activeJMIcon",
		imageDir : "img/jwim",
		baseZIndex : 5000,
		alwaysShowIcons : true,
		taskbar : null,
		container : document.body,
		showTitleBar : true,
		showMaximizer : true,
		showIconizer : true,
		showResizer : true,
		showClose : true,
		defaultX : 10,
		defaultY : 10,
		defaultWidth : 500,
		defaultHeight : 350,
		defaultState : "window",
		buttonSize : 16,
		shiftOffset : 20,
		bottomMargin : 16,
		movable : true,
		httpErrorHandler : null,
		autoCheckResize : true,
		containerBoundaries : 40,
		iconWidth : 120,
		resizeIcons : true,
		afterLoad : null,
		cacheXHR : false
	};
	if (c && typeof c == "object") {
		for ( var b in c) {
			this.opts[b] = c[b]
		}
	}
	if (this.opts.autoCheckResize) {
		jwim.Utils.addEvent(window, "resize", (function(a) {
			return function() {
				a.checkResize()
			}
		})(this))
	}
};
jwim.Manager.prototype.createWindow = function(b) {
	b = b || {};
	var f = 3;
	var i = "position:absolute;top:2px;width:" + this.opts.buttonSize
			+ "px;height:" + this.opts.buttonSize + "px;";
	var g = function(a) {
		this.style.opacity = ".5";
		if (!a) {
			window.event.cancelBubble = true
		} else {
			a.stopPropagation()
		}
		return false
	};
	var h = function(a) {
		this.style.opacity = "1"
	};
	if (b.id && this.getWindow(b.id) != null) {
		return null
	}
	var d = b.container || this.opts.container;
	var c = b.state || this.opts.defaultState;
	var k = new jwim.Window(b, this);
	k.win = document.createElement("div");
	k.content = document.createElement("div");
	k.loading = document.createElement("div");
	if (this.opts.shiftOffset > 0) {
		var j;
		do {
			for (j = 0; j < this.windows.length; j++) {
				var e = this.windows[j];
				if ((e.x == k.x || e.userX == k.x)
						&& (e.y == k.y || e.userY == k.y)) {
					k.x += this.opts.shiftOffset;
					k.y += this.opts.shiftOffset;
					break
				}
			}
		} while (j != this.windows.length)
	}
	k.userX = k.x;
	k.userY = k.y;
	k.win.className = this.opts.classWindow;
	k.win.style.cssText = "z-index:" + this.opts.baseZIndex
			+ ";position:absolute;top:" + (k.y) + "px;left:" + (k.x) + "px;";
	k.content.className = this.opts.classContent;
	k.content.style.cssText = "position:relative;margin:0;width:0px;height:0px";
	k.win.onmousedown = jwim.Callbacks.dragStart(k);
	if (this.opts.showTitleBar) {
		k.title = document.createElement("div");
		k.titleSpan = document.createElement("span");
		k.title.style.cssText = "position:relative;cursor:default";
		k.titleSpan.innerHTML = k.titleText;
		k.title.appendChild(k.titleSpan);
		k.title.onmousedown = function() {
			return false
		};
		k.title.className = this.opts.classTitle;
		if (this.opts.showClose) {
			k.components.close = document.createElement("div");
			k.components.close.style.cssText = i + "right:" + f
					+ "px;background-image:url(" + this.opts.imageDir
					+ "/close.png)";
			k.components.close.onclick = function() {
				k.close()
			};
			k.components.close.onmousedown = g;
			k.components.close.onmouseout = h;
			k.title.appendChild(k.components.close);
			f += this.opts.buttonSize + 2
		}
		if (this.opts.showMaximizer) {
			k.components.maximizer = document.createElement("div");
			k.components.maximizer.style.cssText = i + "right:" + f
					+ "px;background-image:url(" + this.opts.imageDir
					+ "/maximize.png);";
			k.components.maximizer.onclick = function() {
				k._maximize()
			};
			k.components.maximizer.onmousedown = g;
			k.components.maximizer.onmouseout = h;
			k.title.appendChild(k.components.maximizer);
			f += this.opts.buttonSize + 2
		}
		if (this.opts.taskbar && this.opts.showIconizer) {
			k.components.iconizer = document.createElement("div");
			k.components.iconizer.style.cssText = i + "right:" + f
					+ "px;background-image:url(" + this.opts.imageDir
					+ "/iconize.png);";
			k.components.iconizer.onclick = function(a) {
				k._iconify()
			};
			k.components.iconizer.onmousedown = g;
			k.components.iconizer.onmouseout = h;
			k.title.appendChild(k.components.iconizer);
			f += this.opts.buttonSize + 2
		}
		k.win.appendChild(k.title);
		k.components.titlebar = k.title
	}
	k.win.appendChild(k.content);
	k.components.content = k.content;
	k.loading.style.cssText = i + "right:" + f + "px;background-image:url("
			+ this.opts.imageDir + "/loading.gif);visibility:hidden;";
	if (k.title) {
		k.title.appendChild(k.loading)
	} else {
		k.win.appendChild(k.loading)
	}
	k.components.loading = k.loading;
	if (this.opts.showResizer) {
		k.resizer = document.createElement("div");
		k.resizer.style.cssText = "position:absolute;background-image:url("
				+ this.opts.imageDir
				+ "/resize.png);width:14px;height:14px;right:1px;bottom:1px";
		k.win.appendChild(k.resizer);
		k.components.resizer = k.resizer
	}
	d.appendChild(k.win);
	k.components.window = k.win;
	k._setSize(k.w, k.h, false, "");
	this.windows.push(k);
	if (this.opts.taskbar && this.opts.alwaysShowIcons) {
		k._createTaskbarIcon()
	}
	this._selectWindow(k, true);
	if (c != "window") {
		k.setState(c)
	}
	return k
};
jwim.Manager.prototype.getWindow = function(c) {
	for ( var b = 0; b < this.windows.length; b++) {
		if (this.windows[b].id == c) {
			return this.windows[b]
		}
	}
	return null
};
jwim.Manager.prototype.getSelectedWindow = function() {
	return this.selectedWindow
};
jwim.Manager.prototype.getAllWindows = function() {
	var c = [];
	for ( var b = this.windows.length - 1; b >= 0; b--) {
		c.push(this.windows[b])
	}
	return c
};
jwim.Manager.prototype.getContainerHeight = function() {
	if (this.opts.container == document.body) {
		return jwim.Utils.getBodySize().height
	}
	return this.opts.container.clientHeight
};
jwim.Manager.prototype.getContainerWidth = function() {
	if (this.opts.container == document.body) {
		return jwim.Utils.getBodySize().width
	}
	return this.opts.container.clientWidth
};
jwim.Manager.prototype.checkResize = function() {
	for ( var c = 0; c < this.windows.length; c++) {
		if (this.windows[c].state != "maximized") {
			continue
		}
		var e = this.windows[c].win.offsetWidth
				- parseInt(this.windows[c].win.style.width);
		var f = this.windows[c].win.offsetHeight
				- parseInt(this.windows[c].win.style.height);
		var b = this.windows[c].getContainerWidth() - e;
		var d = this.windows[c].getContainerHeight() - f;
		this.windows[c]._setSize(b, d, false, "resize")
	}
	if (this.opts.taskbar && this.opts.resizeIcons) {
		this._resizeIcons()
	}
};
jwim.Manager.prototype._getNewId = function() {
	var a = this.nextid;
	this.nextid++;
	return a
};
jwim.Manager.prototype._selectWindow = function(f) {
	if (f == this.selectedWindow || !f.scope) {
		return
	}
	if (this.selectedWindow && this.selectedWindow.ondeselect) {
		this.selectedWindow.ondeselect()
	}
	if (!f.alwaysOnTop) {
		for ( var d = 0; d < this.windows.length; d++) {
			if (this.windows[d] == f) {
				var e = this.windows.splice(d, 1);
				for ( var c = this.windows.length - 1; c >= 0; c--) {
					if (!this.windows[c].alwaysOnTop) {
						break
					}
				}
				this.windows.splice(c + 1, 0, e[0]);
				break
			}
		}
	}
	for ( var d = 0; d < this.windows.length; d++) {
		this.windows[d].win.style.zIndex = (this.opts.baseZIndex + d);
		this.windows[d].win.className = this.opts.classWindow;
		if (this.windows[d].taskbarIcon) {
			this.windows[d].taskbarIcon.className = this.opts.classIcon
		}
	}
	f.win.style.visibility = "inherit";
	if (!this.opts.alwaysShowIcons && f.taskbarIcon != null) {
		f._removeTaskbarIcon()
	}
	f.win.className = this.opts.classActiveWindow;
	if (f.taskbarIcon) {
		f.taskbarIcon.className = this.opts.classActiveIcon
	}
	this.selectedWindow = f;
	if (f.state == "icon" || f.state == "hidden") {
		f.state = f.prvState;
		f.prvState = null
	}
	if (f.onselect) {
		f.onselect()
	}
};
jwim.Manager.prototype._destroyWindow = function(e) {
	for ( var d = 0; d < this.windows.length; d++) {
		if (this.windows[d] == e) {
			if (!this.windows[d]._unload(false)) {
				return false
			}
			this.windows[d].getContainer().removeChild(this.windows[d].win);
			if (this.windows[d].taskbarIcon != null) {
				this.windows[d]._removeTaskbarIcon()
			}
			var f = this.windows.splice(d, 1)[0];
			for ( var c = 0; c < this.windows.length; c++) {
				this.windows[c].win.style.zIndex = (this.opts.baseZIndex + c)
			}
			//sen's mod:
			if(this.opts.onclose){
				this.opts.onclose();
			}
//			if (f.onclose) {
//				f.onclose()
//			}
			f.scope = null;
			f = null;
			var g = this._getFirstVisibleWindow();
			if (g) {
				g.select()
			}
			return
		}
	}
	return null
};
jwim.Manager.prototype._getFirstVisibleWindow = function() {
	for ( var b = (this.windows.length - 1); b >= 0; b--) {
		if (this.windows[b].win.style.visibility != "hidden") {
			return this.windows[b]
		}
	}
	return null
};
jwim.Manager.prototype._resizeIcons = function() {
	function d(h, a) {
		var i = parseInt(jwim.Utils.getStyle(h, a));
		return (isNaN(i) ? 0 : i)
	}
	var b;
	var g = [];
	for (b = 0; b < this.windows.length; b++) {
		if (this.windows[b].taskbarIcon
				&& this.windows[b].taskbarIcon.parentNode == this.opts.taskbar) {
			g.push(this.windows[b].taskbarIcon)
		}
	}
	if (g.length < 1) {
		return
	}
	var f = this.opts.taskbar.clientWidth
			- d(this.opts.taskbar, "padding-left")
			- d(this.opts.taskbar, "padding-right") - 1;
	var c = parseInt(f / g.length);
	for (b = 0; b < g.length; b++) {
		var e = (g[b].offsetWidth + d(g[b], "margin-left") + d(g[b],
				"margin-right"))
				- d(g[b], "width");
		if ((this.opts.iconWidth + e) > c) {
			g[b].style.width = (c - e - 1) + "px"
		} else {
			g[b].style.width = this.opts.iconWidth + "px"
		}
	}
};
jwim.Window = function(b, a) {
	this.wm = a;
	this.manager = a;
	this.id = b.id || a._getNewId();
	this.w = (typeof b.width == "number" ? b.width : a.opts.defaultWidth);
	this.h = (typeof b.height == "number" ? b.height : a.opts.defaultHeight);
	this.x = (typeof b.x == "number" ? b.x : a.opts.defaultX);
	this.y = (typeof b.y == "number" ? b.y : a.opts.defaultY);
	this.userW = this.w;
	this.userH = this.h;
	this.userX = null;
	this.userY = null;
	this.movable = (typeof b.movable == "undefined" ? a.opts.movable
			: b.movable);
	this.alwaysOnTop = b.alwaysOnTop || false;
	this.titleText = b.title || "";
	this.title = null;
	this.titleSpan = null;
	this.state = "window";
	this.prvState = null;
	this.win = null;
	this.content = null;
	this.resizer = null;
	this.taskbarIcon = null;
	this.taskbarIconSpan = null;
	this.currentUrl = null;
	this.afterLoad = b.afterLoad || a.opts.afterLoad;
	this.onunload = null;
	this.onselect = null;
	this.onresize = null;
	this.onmove = null;
	this.oniconize = null;
	this.ondeselect = null;
	this.onclose = null;
	this.onhttperror = null;
	this.scope = new jwim.Scope(this);
	this.components = {
		titlebar : null,
		window : null,
		content : null,
		maximizer : null,
		iconizer : null,
		close : null,
		resizer : null,
		icon : null,
		loading : null
	}
};
jwim.Window.prototype.getElement = function(c, e) {
	if (!e) {
		var e = this.content
	}
	for ( var b = 0; b < e.childNodes.length; b++) {
		if (e.childNodes[b].getAttribute
				&& e.childNodes[b].getAttribute("data-wid") == c) {
			return e.childNodes[b]
		}
		var d = this.getElement(c, e.childNodes[b]);
		if (d) {
			return d
		}
	}
	return null
};
jwim.Window.prototype.setState = function(a) {
	switch (a) {
	case "maximized":
		if (this.state == "maximized") {
			return
		}
		this._maximize();
		return;
	case "window":
		if (this.state == "maximized") {
			this._maximize();
			return
		}
		this.state = "window";
		this.select();
		return;
	case "icon":
		this._iconify();
		return;
	case "hidden":
		this.hide();
		return
	}
};
jwim.Window.prototype.setSize = function(a, b) {
	this.state = "window";
	this._setSize(a, b, false, "resize");
	this.userW = a;
	this.userH = b
};
jwim.Window.prototype.setPosition = function(a, b) {
	this._setPosition(a, b);
	if (this.onmove) {
		this.onmove(a, b)
	}
};
jwim.Window.prototype._setPosition = function(a, b) {
	this.state = "window";
	this.win.style.left = a + "px";
	this.win.style.top = b + "px";
	this.x = this.userX = a;
	this.y = this.userY = b
};
jwim.Window.prototype.close = function() {
	this.manager._destroyWindow(this)
};
jwim.Window.prototype.select = function() {
	this.manager._selectWindow(this)
};
jwim.Window.prototype.setContent = function(b, a) {
	var e, d = /<script\b[\s\S]*?>([\s\S]*?)<\/script/i;
	var f = null;
	if (!a) {
		if (!this._unload(true)) {
			return false
		}
		a = this.content;
		f = this.afterLoad
	}
	a.innerHTML = b.replace(/<script.*?>[\s\S]*?<\/.*?script>/gi, "");
	this.convertElementsAttributes(a);
	if (d.test(b)) {
		var c = /<script\b[\s\S]*?>([\s\S]*?)<\/script/gi;
		while (e = c.exec(b)) {
			this.scope._eval(e[1])
		}
	}
	if (f) {
		f(this)
	}
};
jwim.Window.prototype.convertElementsAttributes = function(o) {
	var evnames = [ "onchange", "onsubmit", "onreset", "onselect", "onblur",
			"onfocus", "onkeydown", "onkeypress", "onkeyup", "onclick",
			"ondblclick", "onmousedown", "onmousemove", "onmouseout",
			"onmouseover", "onmouseup" ];
	var code;
	function attachEventCode(code, thisw) {
		if (typeof code != "string") {
			code = code.toString();
			code = code.substr(code.indexOf("{") + 1);
			code = code.substr(0, code.lastIndexOf("}"))
		}
		return function(event) {
			if (!event) {
				var event = window.event
			}
			eval("var event_attribute=function(event,thisw){" + code + "}");
			return event_attribute.apply(this, [ event, thisw ])
		}
	}
	var elements = o.getElementsByTagName("*");
	for ( var a = 0; a < elements.length; a++) {
		var c = elements[a];
		for ( var b = 0; b < evnames.length; b++) {
			if (c.getAttribute && (code = c.getAttribute(evnames[b]))) {
				c[evnames[b]] = attachEventCode(code, this)
			}
		}
		if (c.tagName == "A" && c.target == ""
				&& (code = c.getAttribute("href"))) {
			if (code.toLowerCase() != "javascript:void(0)" && code != "#") {
				c.onclick = (function(w, c) {
					return function() {
						w.loadUrl(c);
						return false
					}
				})(this, code)
			}
		}
	}
};
jwim.Window.prototype.loadUrl = function(b, g) {
	var d = false;
	if (this.onunload) {
		if (this.onunload() == false) {
			return false
		}
	}
	this.showLoading();
	if (window.XMLHttpRequest && !(window.ActiveXObject)) {
		try {
			d = new XMLHttpRequest()
		} catch (f) {
			d = false
		}
	} else {
		if (window.ActiveXObject) {
			try {
				d = new ActiveXObject("Msxml2.XMLHTTP")
			} catch (f) {
				try {
					d = new ActiveXObject("Microsoft.XMLHTTP")
				} catch (f) {
					d = false
				}
			}
		}
	}
	if (!d) {
		alert("AJAX not supported by this browser");
		return false
	}
	d.onreadystatechange = (function(e) {
		return function() {
			if (d.readyState == 4) {
				e.showLoading(false);
				switch (d.status) {
				case 200:
					e.onunload = null;
					e.currentUrl = b;
					e.setContent(d.responseText);
					if (g) {
						g(e)
					}
					break;
				default:
					if (e.onhttperror) {
						e.onhttperror(d, b);
						return
					}
					if (e.manager.opts.httpErrorHandler) {
						e.manager.opts.httpErrorHandler(d, b, e);
						return
					}
					alert("HTTP Error: " + d.status + "\n" + b)
				}
			}
		}
	})(this);
	if (!this.manager.opts.cacheXHR) {
		var c = (new Date).getTime();
		var a = b.replace(/(\?|&)_=.*?(&|$)/, "$1_=" + c + "$2");
		b = a + ((a === b) ? ((/\?/).test(b) ? "&" : "?") + "_=" + c : "")
	}
	d.open("GET", b, true);
	d.send("")
};
jwim.Window.prototype.showLoading = function(a) {
	this.loading.style.visibility = (typeof a == "undefined" || a ? "inherit"
			: "hidden")
};
jwim.Window.prototype.setTitle = function(a) {
	if (this.title) {
		this.titleSpan.innerHTML = a;
		this.titleText = a
	}
	if (this.taskbarIcon) {
		this.taskbarIconSpan.innerHTML = a;
		this.taskbarIcon.setAttribute("title", a)
	}
};
jwim.Window.prototype.setMovable = function(a) {
	this.movable = a
};
jwim.Window.prototype.setAlwaysOnTop = function(a) {
	if (a) {
		this.select()
	}
	this.alwaysOnTop = a
};
jwim.Window.prototype.getComponent = function(a) {
	return this.components[a]
};
jwim.Window.prototype.isMovable = function() {
	return this.movable
};
jwim.Window.prototype.isAlwaysOnTop = function() {
	return this.alwaysOnTop
};
jwim.Window.prototype.getWidth = function() {
	return this.w
};
jwim.Window.prototype.getHeight = function() {
	return this.h
};
jwim.Window.prototype.getX = function() {
	return this.x
};
jwim.Window.prototype.getY = function() {
	return this.y
};
jwim.Window.prototype.getId = function() {
	return this.id
};
jwim.Window.prototype.getTitle = function() {
	return this.titleText
};
jwim.Window.prototype.getCurrentUrl = function(a) {
	return (this.manager.opts.cacheXHR || a ? this.currentUrl : this.currentUrl
			.replace(/(\?|&)_=.*/, ""))
};
jwim.Window.prototype.getState = function() {
	return this.state
};
jwim.Window.prototype.getManager = function() {
	return this.manager
};
jwim.Window.prototype.getContentWidth = function() {
	return parseInt(this.content.style.width)
};
jwim.Window.prototype.getContentHeight = function() {
	return parseInt(this.content.style.height)
};
jwim.Window.prototype.getContainer = function() {
	return this.win.parentNode
};
jwim.Window.prototype.getContainerWidth = function() {
	var a = this.getContainer();
	if (a == document.body) {
		return jwim.Utils.getBodySize().width
	}
	return a.clientWidth
};
jwim.Window.prototype.getContainerHeight = function() {
	var a = this.getContainer();
	if (a == document.body) {
		return jwim.Utils.getBodySize().height
	}
	return a.clientHeight
};
jwim.Window.prototype.attachTo = function(a) {
	a = a || this.manager.opts.container;
	a.appendChild(this.win)
};
jwim.Window.prototype._maximize = function() {
	if (this.state != "maximized") {
		var a, c;
		var b = this.win.offsetWidth - parseInt(this.win.style.width);
		var d = this.win.offsetHeight - parseInt(this.win.style.height);
		this.win.style.top = 0 + "px";
		this.win.style.left = 0 + "px";
		this.x = this.y = 1;
		this.state = "maximized";
		a = this.getContainerWidth() - b;
		c = this.getContainerHeight() - d;
		this._setSize(a, c, false, "maximize")
	} else {
		this.state = "window";
		this._setSize(this.userW, this.userH, false, "restore");
		this._setPosition(this.userX, this.userY)
	}
};
jwim.Window.prototype._setSize = function(b, d, a, e) {
	var f = 0;
	this.win.style.height = d + "px";
	this.win.style.width = b + "px";
	var g = b - (this.content.offsetWidth - parseInt(this.content.style.width));
	var c = d
			- (this.content.offsetHeight - parseInt(this.content.style.height))
			- this.manager.opts.bottomMargin - this.content.offsetTop;
	this.content.style.height = c + "px";
	this.content.style.width = g + "px";
	if (!a) {
		this.w = b;
		this.h = d
	}
	if (e && this.onresize) {
		this.onresize(b, d, e)
	}
};
jwim.Window.prototype.autoSize = function() {
	this.win.style.height = 0 + "px";
	this.win.style.width = 0 + "px";
	this.content.style.height = 0 + "px";
	this.content.style.width = 0 + "px";
	var a = this.content.scrollWidth + 30, b = this.content.scrollHeight + 70;
	this.setSize(a, b);
	this.state = "window"
};
jwim.Window.prototype.hide = function() {
	this.prvState = this.state;
	this.state = "hidden";
	this.win.style.visibility = "hidden"
};
jwim.Window.prototype._iconify = function() {
	if (!this.manager.opts.taskbar || this.state == "icon") {
		return
	}
	if (!this.manager.opts.alwaysShowIcons) {
		this._createTaskbarIcon()
	}
	this.taskbarIcon.className = this.manager.opts.classIcon;
	if (this.manager.selectedWindow == this) {
		this.manager.selectedWindow = null
	}
	this.hide();
	this.state = "icon";
	var a = this.manager._getFirstVisibleWindow();
	if (a) {
		a.select()
	}
	if (this.oniconize) {
		this.oniconize()
	}
};
jwim.Window.prototype._createTaskbarIcon = function() {
	if (!this.manager.opts.taskbar) {
		return
	}
	this.taskbarIcon = document.createElement("div");
	this.taskbarIconSpan = document.createElement("span");
	this.taskbarIcon.className = this.manager.opts.classIcon;
	this.taskbarIconSpan.innerHTML = this.titleText;
	this.taskbarIcon.setAttribute("title", this.titleText);
	this.taskbarIcon.style.width = this.manager.opts.iconWidth + "px";
	this.taskbarIcon.onclick = (function(a) {
		return function(b) {
			a.select()
		}
	})(this);
	this.taskbarIcon.appendChild(this.taskbarIconSpan);
	this.manager.opts.taskbar.appendChild(this.taskbarIcon);
	this.components.icon = this.taskbarIcon;
	if (this.manager.opts.resizeIcons) {
		this.manager._resizeIcons()
	}
};
jwim.Window.prototype._removeTaskbarIcon = function() {
	this.taskbarIcon.parentNode.removeChild(this.taskbarIcon);
	this.taskbarIcon = null;
	if (this.manager.opts.resizeIcons) {
		this.manager._resizeIcons()
	}
};
jwim.Window.prototype._unload = function(a) {
	if (this.onunload) {
		if (this.onunload() == false) {
			return false
		}
	}
	this.onunload = null;
	this.onselect = null;
	this.onresize = null;
	this.onmove = null;
	this.oniconize = null;
	this.ondeselect = null;
	this.onhttperror = null;
	if (a) {
		this.onclose = null;
		this.scope = new jwim.Scope(this)
	}
	return true
};
jwim.Utils.getEventXY = function(a) {
	if (window.event) {
		return {
			x : window.event.clientX + document.body.scrollLeft
					+ document.documentElement.scrollLeft,
			y : window.event.clientY + document.body.scrollTop
					+ document.documentElement.scrollTop
		}
	} else {
		return {
			x : a.pageX,
			y : a.pageY
		}
	}
};
jwim.Utils.addEvent = function(b, a, c) {
	if (window.addEventListener) {
		b.addEventListener(a, c, false)
	} else {
		b.attachEvent("on" + a, c)
	}
};
jwim.Utils.removeEvent = function(b, a, c) {
	if (window.removeEventListener) {
		b.removeEventListener(a, c, false)
	} else {
		b.detachEvent("on" + a, c)
	}
};
jwim.Utils.getBodySize = function() {
	var a = (window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth);
	var b = (window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight);
	return {
		width : a,
		height : b
	}
};
jwim.Utils.getStyle = function(b, c) {
	if (b.currentStyle) {
		var a = c.replace(/-([a-z])/ig, function(e, d) {
			return d.toUpperCase()
		});
		return b.currentStyle[c] || b.currentStyle[a]
	} else {
		if (window.getComputedStyle) {
			return document.defaultView.getComputedStyle(b, null)
					.getPropertyValue(c)
		}
	}
	return null
};
jwim.Callbacks.move = function(a) {
	return function(g) {
		var f, b, i;
		if (a.draggingWin == null) {
			return
		}
		if (!g) {
			var g = window.event
		}
		a.draggingWin.state = "window";
		f = jwim.Utils.getEventXY(g);
		a.mouse.cur.x = f.x;
		a.mouse.cur.y = f.y;
		i = (a.mouse.cur.y - a.mouse.click.y);
		b = (a.mouse.cur.x - a.mouse.click.x);
		if (a.opts.containerBoundaries > 0) {
			var c = -1
					* (a.draggingWin.getWidth() - a.opts.containerBoundaries);
			var h = a.draggingWin.getContainerWidth()
					- a.opts.containerBoundaries;
			var d = a.draggingWin.getContainerHeight()
					- a.opts.containerBoundaries;
			if (b < c) {
				b = c
			}
			if (b > h) {
				b = h
			}
			if (i > d) {
				i = d
			}
		}
		if (a.opts.containerBoundaries > -1) {
			if (i < 0) {
				i = 0
			}
		}
		a.draggingWin.win.style.top = i + "px";
		a.draggingWin.win.style.left = b + "px";
		if (a.draggingWin.onmove) {
			a.draggingWin.onmove(b, i)
		}
	}
};
jwim.Callbacks.resize = function(a) {
	return function(f) {
		var d, b, c;
		if (a.draggingWin == null) {
			return
		}
		a.draggingWin.state = "window";
		if (!f) {
			var f = window.event
		}
		d = jwim.Utils.getEventXY(f);
		a.mouse.cur.x = d.x;
		a.mouse.cur.y = d.y;
		c = (a.draggingWin.h + (a.mouse.cur.y - a.mouse.click.y));
		b = (a.draggingWin.w + (a.mouse.cur.x - a.mouse.click.x));
		if (b < 80) {
			b = 80
		}
		if (c < 60) {
			c = 60
		}
		a.draggingWin._setSize(b, c, true, "resize")
	}
};
jwim.Callbacks.dragStop = function(a) {
	return function() {
		if (a.draggingWin == null) {
			return
		}
		if (a.draggingWin.state == "window") {
			a.draggingWin.userW = a.draggingWin.w = parseInt(a.draggingWin.win.style.width);
			a.draggingWin.userH = a.draggingWin.h = parseInt(a.draggingWin.win.style.height);
			a.draggingWin.userX = a.draggingWin.x = parseInt(a.draggingWin.win.style.left);
			a.draggingWin.userY = a.draggingWin.y = parseInt(a.draggingWin.win.style.top)
		}
		jwim.Utils.removeEvent(document, "mousemove", a.moveCallback);
		jwim.Utils.removeEvent(document, "mousemove", a.resizeCallback);
		jwim.Utils.removeEvent(document, "mouseup", a.dragStop);
		if (typeof document.onselectstart != "undefined") {
			jwim.Utils.removeEvent(document, "selectstart",
					jwim.Callbacks.onSelectStart)
		}
		a.draggingWin = null
	}
};
jwim.Callbacks.dragStart = function(a) {
	return function(f) {
		var c, b, d;
		if (!f) {
			var f = window.event
		}
		a.select();
		if (f.target) {
			c = f.target
		} else {
			if (f.srcElement) {
				c = f.srcElement
			}
		}
		if (c.nodeType == 3) {
			c = c.parentNode
		}
		switch (c) {
		case a.win:
		case a.title:
		case a.titleSpan:
		case a.resizer:
			a.manager.draggingWin = a;
			d = jwim.Utils.getEventXY(f);
			a.manager.mouse.click.x = d.x;
			a.manager.mouse.click.y = d.y;
			b = a.manager.resizeCallback;
			if (c != a.resizer) {
				if (a.movable == false) {
					return false
				}
				a.manager.mouse.click.x -= a.x;
				a.manager.mouse.click.y -= a.y;
				b = a.manager.moveCallback
			}
			jwim.Utils.addEvent(document, "mousemove", b);
			jwim.Utils.addEvent(document, "mouseup", a.manager.dragStop);
			if (typeof document.onselectstart != "undefined") {
				jwim.Utils.addEvent(document, "selectstart",
						jwim.Callbacks.onSelectStart)
			}
			return false
		}
	}
};
jwim.Callbacks.onSelectStart = function() {
	return false
};